const jsonwebtoken = require('jsonwebtoken');
const secret_key = 'FOOT_MARK'

function setToken(user) {
  const token = jsonwebtoken.sign({
    data: user,
    exp: Math.floor(Date.now() / 1000) + (6 * 60 * 60),
  }, secret_key);
  return token
}

function getToken(token='token') {
  try {
    jsonwebtoken.verify(token, secret_key)
  } catch (error) {
    console.log('token.js getToken:',error)
  }
}


module.exports = {
  setToken,getToken,secret_key
}